<template>
  <div class="wrapper">
    <!--list.length默认显示第一张-->
    <swiper :options="swiperOption" v-if="showSwiper">
      <!-- slides -->
      <swiper-slide v-for="item of list" :key="item.id">
        <img class="swper-img"
             :src="item.imgUrl"
             alt="">
      </swiper-slide>
      <!-- Optional controls -->
      <div class="swiper-pagination" slot="pagination"></div>
      <!--左右箭头-->
      <!--<div class="swiper-button-prev" slot="button-prev"></div>-->
      <!--<div class="swiper-button-next" slot="button-next"></div>-->
      <!--滚动条-->
      <!--<div class="swiper-scrollbar" slot="scrollbar"></div>-->
    </swiper>
  </div>
</template>

<script>
  export default {
    name: 'HomeSwiper',
    props:{
      list:Array
    },
    data () {
      return {
        swiperOption: {
          pagination: '.swiper-pagination',
          //循环
          loop: true,
          autoplay:5000

        },
        swiperList: [
          {
            id: '0001',
            imgUrl: 'https://img1.360buyimg.com/pop/jfs/t1/29852/4/10279/100860/5c8722c3Ee34669d1/a08c1924d65f3a7e.jpg'
          },
          {
            id: '0002',
            imgUrl: 'https://m.360buyimg.com/babel/jfs/t1/31931/5/4952/99171/5c8216d7Eadd63188/b78ab41bb0b10179.jpg'
          }
        ]
      }
    },
    computed:{
      showSwiper (){
        return this.list.length
      }
    }
  }
</script>

<style lang="stylus" scoped>
  /*样式穿透*/
  .wrapper >>> .swiper-pagination-bullet-active
    background red !important

  .wrapper
    width 100%
    height 3.5rem
    /*overflow hidden*/
    /*padding-bottom 5%*/

    .swper-img
      width 100%
      height 3.5rem

</style>
